<template>
    <div>
        <h3>登录</h3>
        <table class="table table-bordered">
            <tbody>
                <tr>
                    <td>手机号</td>
                    <td>
                        <input type="text" v-model="deng.shouji">
                    </td>
                </tr>
                <tr>
                    <td>密码</td>
                    <td>
                        <input type="password" v-model="deng.mima">
                    </td>
                </tr>
                <tr>
                    <td></td>
                    <td>
                        <input type="button" value="登录" class="btn btn-primary" @click="denglu">
                    </td>
                </tr>
            </tbody>
        </table>
    </div>
</template>

<script setup lang="ts">
import {ref,reactive} from 'vue'
import axios from 'axios';
import {useRoute,useRouter} from 'vue-router'
const route=useRoute();
const router=useRouter();
let deng:any=reactive({
    shouji:'',
    mima:''
})
const denglu=()=>{
    axios({
        url:'/api/Deng/deng',
        method:'get',
        params:deng
    })
    .then((res)=>{
        console.log(res);
        if(res.data==-1)
    {
        alert('用户名不存在');
        return;
    }
    else if(res.data==-2)
    {
        alert('密码错误');
        return;
    }
    else
    {
        alert('登录成功');
        router.push("/Dshow")
    }
    })
    .catch((err)=>{
        console.log(err);
    })
}
</script>

<style scoped>

</style>